package cn.ljy.uem.dao;

import cn.ljy.authority.dao.BaseMapper;
import cn.ljy.uem.model.SchoolCourse;
import cn.ljy.uem.model.SchoolTeacher;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.List;

/**
 * 教师的数据层
 *
 * @author 小锋
 * @date 2022/07/18
 */
@Mapper
public interface SchoolTeacherMapper extends BaseMapper<SchoolTeacher> {


    /**
     * 根据指定专业包含的教师信息集合
     * @param majorId
     * @return
     */
    List<SchoolTeacher> findAllTeacherByMajorId(Integer majorId);

    /**
     * 根据指定专业获取专业下的所有的教师数量
     * @param majorId
     * @return
     */
    @Select("select count(1) from school_teacher where major_id = #{majorId}")
    int countAllTeacherByMajorId(Integer majorId);


    /**
     * 显示所有教师的名称
     * @return
     */
    @Select("select name from school_teacher order by id asc")
    List<String> getAllNames();


    /**
//     * 根据指定教学班获取教学班下的所有的教师数量
//     *
//     * @param teachingClassId
//     * @return int
//     */
//    @Select("select count(1) from school_teacher where teaching_class_id = #{teachingClassId}")
//    int countAllTeacherByTeachingClassId(Integer teachingClassId);


    /**
     * 获取user表中相对应的教师信息
     */
    @Select("SELECT * FROM school_teacher WHERE school_teacher.user_id=#{userid}")
    SchoolTeacher getTeacherByUserId(java.io.Serializable userid);

    /**
     * 获取user表中相对应的教师id
     * @param userid
     * @return
     */
    @Select("SELECT id FROM school_teacher WHERE user_id=#{userid}")
    Long getIdByUserId(java.io.Serializable userid);


    /**
     * 获取教师所有课程
     *
     */
    @Select("SELECT * FROM school_course WHERE school_course.teacher_id=#{teacherid}")
    List<SchoolCourse> getCourseByTeacherId(java.io.Serializable teacherid);

    /**
     * 根据教师工号查找该教师是否已存在
     */
    @Select("SELECT count(1) FROM school_teacher WHERE school_teacher.teacher_number=#{teacherNumber}")
    int countByTeacherNumber(String teacherNumber);

    @Select("select count(1) from school_student where student_number=#{studentNumber} and id!=#{id}")
    int countByTeacherNumberAndNotId(String studentNumber, Serializable id);

    /**
     * 通过教师ID 查找出教师对应账户ID 用于删除
     *
     */

    List<Serializable> findUserIdsByIds(java.io.Serializable[] ids);

}
